<!doctype HTML>
{% macro alert(should_alert) -%}
  {% if should_alert %}
    class="alert"
  {% endif %}
{%- endmacro %}
<html>
    <head>
      <title>Code Yellow Status</title>
      <script src="/bower_components/webcomponentsjs/webcomponents.js"></script>
      <link rel="import" href="../lib/analytics.html">
    </head>
    <link href='//fonts.googleapis.com/css?family=RobotoDraft:regular,bold,italic,thin,light,bolditalic,black,medium&lang=en' rel='stylesheet' type='text/css'>
    <style>
      body {
        font-family: 'RobotoDraft';
      }
      .alert {
        color: red;
      }
    </style>
    <body>
      <table border=1 cellpadding=15 cellspacing="0">
          <tr><th colspan="2">CQ Status, last hour</th></tr>
          <tr><td>Chromium</td><td>Blink</td></tr>
          <tr>
              <td {{alert(cq_latency.chromium.should_alert)}}>
                {% if not cq_latency.chromium.p50 %}
                  <div>50th percentile: N/A</div>
                  <div>90th percentile: N/A</div>
                {% else %}
                  <div>50th percentile: {{cq_latency.chromium.p50}} minutes</div>
                  <div>90th percentile: {{cq_latency.chromium.p90}} minutes</div>
                {% endif %}
                <div>Length: {{cq_latency.chromium.length}}</div>
                <a href="/cq/chromium">graphs</a>
              </td>
              <td {{alert(cq_latency.blink.should_alert)}}>
                {% if not cq_latency.blink.p50 %}
                  <div>50th percentile: N/A</div>
                  <div>90th percentile: N/A</div>
                {% else %}
                  <div>50th percentile: {{cq_latency.blink.p50}} minutes</div>
                  <div>90th percentile: {{cq_latency.blink.p90}} minutes</div>
                {% endif %}
                <div>Length: {{cq_latency.blink.length}}</div>
                <a href="/cq/blink">graphs</a>
              </td>
          </tr>
          <tr><th colspan="2">Tree Open Time, Last 7 days</th></tr>
          <tr><td>Chromium</td><td>Blink</td></tr>
          <tr>
            {% if tree_status.chromium %}
            <td {{alert(tree_status.chromium.should_alert)}}>
              <div>{{"%.2f"|format(tree_status.chromium.percent_open)}}</div>
              <a href="/tree-status/chromium">graphs</a>
            </td>
            {% endif %}
            {% if tree_status.blink %}
            <td {{alert(tree_status.blink.should_alert)}}>
              <div>{{"%.2f"|format(tree_status.blink.percent_open)}}</div>
              <a href="/tree-status/blink">graphs</a>
            </td>
            {% endif %}
          </tr>
          <tr><th colspan="2">Build times, last hour</th></tr>
          <tr><td>Chromium</td><td>Blink</td></tr>
          <tr>
            {% if cycle_time.chromium %}
            <td {{alert(cycle_time.chromium.should_alert)}}>
              <div>{{cycle_time.chromium.num_over_median_slo}} / {{cycle_time.chromium.num_builds}} ({{cycle_time.chromium.percent_over_median_slo}}) over 30 min</div>
              <div>{{cycle_time.chromium.num_over_max_slo}} / {{cycle_time.chromium.num_builds}} ({{cycle_time.chromium.percent_over_max_slo}}) over 60 min</div>
              <a href="/tree/chromium">graphs</a>
            </td>
            {% endif %}
            {% if cycle_time.blink %}
            <td {{alert(cycle_time.blink.should_alert)}}>
              <div>{{cycle_time.blink.num_over_median_slo}} / {{cycle_time.blink.num_builds}} ({{cycle_time.blink.percent_over_median_slo}}) over 30 min</div>
              <div>{{cycle_time.blink.num_over_max_slo}} / {{cycle_time.blink.num_builds}} ({{cycle_time.blink.percent_over_max_slo}}) over 60 min</div>
              <a href="/tree/blink">graphs</a>
            </td>
            {% endif %}
          </tr>
      </table>
      <script> new Analytics('UA-55762617-7'); </script>
    </body>
</html>
